/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.forms;

import com.bs.beans.ConversaoUnidade;
import com.bs.beans.Unidades;
import java.util.ArrayList;

/**
 *
 * @author Bone
 */
public class ConversaoUnidadeForm extends  DialogoForm {

    public ConversaoUnidadeForm() {
        initComponents();
    }

    public ConversaoUnidadeForm(Object bean) {
        super(bean);
        initComponents();
    }

    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        listOrigem = new ArrayList<Unidades>(getEntityManager().getCollection(Unidades.class));
        formularioController = new com.bs.extensoesSwing.FormularioController<ConversaoUnidade>();
        conversorMonetario = new com.bs.converters.ConversorMonetario();
        unidadesRenderer = new com.bs.ListRenderer.UnidadesRenderer();
        listDestino = new ArrayList<Unidades>(getEntityManager().getCollection(Unidades.class));
        tituloFormulario1 = new com.bs.extensoesSwing.TituloFormulario();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        campoNumericoComDecimal1 = new com.bs.extensoesSwing.CampoNumericoComDecimal();
        cancelarFormButton1 = new com.bs.extensoesSwing.CancelarFormButton();
        jSeparator1 = new javax.swing.JSeparator();
        excluirFormButton1 = new com.bs.extensoesSwing.ExcluirFormButton();
        incluirFormButton1 = new com.bs.extensoesSwing.IncluirFormButton();
        alterarFormButton1 = new com.bs.extensoesSwing.AlterarFormButton();

        formularioController.setJanela(this);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${bean}"), formularioController, org.jdesktop.beansbinding.BeanProperty.create("bean"), "");
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${entityManager}"), formularioController, org.jdesktop.beansbinding.BeanProperty.create("entityManager"), "entityManagerFormBind");
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        unidadesRenderer.setText("unidadesRenderer1");

        tituloFormulario1.setTitulo("Cadastro de conversão de unidades");

        jLabel1.setText("Unidade origem:");

        jLabel2.setText("Unidade de destino:");

        jLabel3.setText("Quantidade equivalente:");

        jComboBox1.setRenderer(unidadesRenderer);

        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, listOrigem, jComboBox1);
        bindingGroup.addBinding(jComboBoxBinding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.unidadeOriginal}"), jComboBox1, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"), "unidadeOriginalBind");
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        jComboBox2.setRenderer(unidadesRenderer);

        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, listDestino, jComboBox2);
        bindingGroup.addBinding(jComboBoxBinding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.unidadeParaConversao}"), jComboBox2, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"), "unidadeParaConversao");
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.quantidade}"), campoNumericoComDecimal1, org.jdesktop.beansbinding.BeanProperty.create("text"), "bindQuantidade");
        binding.setSourceUnreadableValue(null);
        binding.setConverter(conversorMonetario);
        bindingGroup.addBinding(binding);

        cancelarFormButton1.setController(formularioController);

        excluirFormButton1.setController(formularioController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.id != null}"), excluirFormButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        binding.setSourceUnreadableValue(false);
        bindingGroup.addBinding(binding);

        incluirFormButton1.setController(formularioController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.id == null}"), incluirFormButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        binding.setSourceUnreadableValue(true);
        bindingGroup.addBinding(binding);

        alterarFormButton1.setController(formularioController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.id != null}"), alterarFormButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        binding.setSourceUnreadableValue(false);
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tituloFormulario1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 512, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoNumericoComDecimal1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(20, 20, 20)))
                .addGap(10, 10, 10))
            .addComponent(jSeparator1)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(incluirFormButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(alterarFormButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(excluirFormButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cancelarFormButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tituloFormulario1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(campoNumericoComDecimal1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cancelarFormButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(excluirFormButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(alterarFormButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(incluirFormButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        bindingGroup.bind();

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.bs.extensoesSwing.AlterarFormButton alterarFormButton1;
    private com.bs.extensoesSwing.CampoNumericoComDecimal campoNumericoComDecimal1;
    private com.bs.extensoesSwing.CancelarFormButton cancelarFormButton1;
    private com.bs.converters.ConversorMonetario conversorMonetario;
    private com.bs.extensoesSwing.ExcluirFormButton excluirFormButton1;
    private com.bs.extensoesSwing.FormularioController<ConversaoUnidade> formularioController;
    private com.bs.extensoesSwing.IncluirFormButton incluirFormButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JSeparator jSeparator1;
    private java.util.List<Unidades> listDestino;
    private java.util.List<Unidades> listOrigem;
    private com.bs.extensoesSwing.TituloFormulario tituloFormulario1;
    private com.bs.ListRenderer.UnidadesRenderer unidadesRenderer;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
